import request from "./request";


//课程分类
export class CourseListApi {

    getCourseCateList() {
        return request({url: '/api/v1/org/course/cate/list', method: 'get'})
    }

    getCourseList({page, cate_id}) {
        cate_id = cate_id === 0 ? '' : cate_id
        let data = {page, cate_id}
        return request({url: '/api/v1/org/course/list', method: 'post', data})
    }
}

//添加课程
export class AddCourseApi {
    saveResource(path, type = 'image') {
        let data = {path, type}
        return request({url: '/api/v1/saveRes', method: 'post', data})
    }

    getMajorList() {
        return request({url: '/api/v1/org/getMajor', method: 'get'})
    }

    getCourseCateList() {
        return request({url: '/api/v1/org/course/cate/list', method: 'get'})
    }

    getClassTime() {
        return request({url: '/api/v1/org/course/class/time', method: 'get'})
    }

    addCourse({cate_id, picture, title, major, status, mode, type, description, skus}) {
        //status:是否开启：0否1是
        //mode:上课方式:1一对一，2集体课
        let data = {cate_id, picture, title, major, status, mode, type, description, skus}
        return request({url: '/api/v1/org/course/create', method: 'post', data})
    }

    //课程详情接口
    getCourseDetail(course_id) {
        let data = {course_id}
        return request({url: '/api/v1/org/course/detail', method: 'post', data})
    }

    updateCourse({course_id, cate_id, picture, title, major, status, mode, type, description, skus}) {
        let data = {course_id, cate_id, picture, title, major, status, mode, type, description, skus}
        return request({url: '/api/v1/org/course/edit', method: 'post', data})
    }
}
